<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "user_log".
 *
 * @property integer $id
 * @property string $idcard
 * @property string $idcard_img
 * @property string $cachet_img
 * @property integer $company_id
 * @property integer  $park_id
 * @property integer $type
 * @property integer $date
 * @property integer $status
 * @property integer $person_id
 * @property string $psw_tmp
 *
 * @property Person $person
 * @property Company $company
 * @property Park $park
 */
class UserLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user_log';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['type', 'status', 'person_id','company_id'], 'required'],
            [['type', 'date', 'status', 'person_id','park_id'], 'integer'],
            [['idcard_img', 'cachet_img','idcard'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '编号',
            'idcard_img' => '身份证图片',
            'cachet_img' => '公章图片',
            'type' => '申请类型',
            'date' => '申请日期',
            'status' => '当前状态',
            'person_id' => '申请人',
            'park_id' => '申请园区',
            'company_id' => '申请公司',
            'idcard'=>'身份证号',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPerson()
    {
        return $this->hasOne(Person::className(), ['id' => 'person_id']);
    }

    public function getCompany()
    {
        return $this->hasOne(Company::className(), ['id' => 'company_id']);
    }

    public function getPark()
    {
        return $this->hasOne(Park::className(), ['id' => 'park_id']);
    }
}
